﻿using System;
using Newtonsoft.Json;

namespace T.FAS.Runtime.Metadata.Entity.DataModel
{
    /// <summary>
    /// 数据查询-排序
    /// </summary>
    [Serializable]
    public class DataQuerySort : ICloneable
    {
        /// <summary>
        /// 主键id
        /// </summary>
        public string ID { get; set; }

        /// <summary>
        /// 数据查询id
        /// </summary>
        public string DataQueryID { get; set; }

        /// <summary>
        /// 数据对象id
        /// </summary>
        public string DataObjectID { get; set; }

        /// <summary>
        /// 数据对象列id
        /// </summary>
        public string DataObjectColumnID { get; set; }

        /// <summary>
        /// 数据查询列id，当且仅当排序列为自定义列时使用
        /// </summary>
        public string DataQueryColumnID { get; set; }

        /// <summary>
        /// 排序表达式，只有当SortType：express时生效
        /// </summary>
        public string SortExpression { get; set; }

        /// <summary>
        /// 排序表达式json内容，只有当SortType：express时生效
        /// </summary>
        public string SortExpressionJson { get; set; }

        /// <summary>
        /// 列类型：0:普通列 1: 表达式列 2:GroupBy列 3:聚合函数列
        /// </summary>
        public ColumnType SortColumnType { get; set; }

        /// <summary>
        /// 排序对象类型：0:列排序 1:表达式排序
        /// </summary>
        public int SortItemType { get; set; }

        /// <summary>
        /// 排序类型：0:ASC 1:DESC
        /// </summary>
        public int SortType { get; set; }

        /// <summary>
        /// 排序条件顺序
        /// </summary>
        public int Sort { get; set; }

        /// <summary>
        /// 数据对象实体, 禁止序列化，反序列化时从DataQuerySource.DataObject引用
        /// </summary>
        [JsonIgnore]
        public DataObject DataObject { get; set; }

        /// <summary>
        /// 数据对象的列实体, 禁止序列化，反序列化时从DataQuerySource.DataObject引用
        /// </summary>
        [JsonIgnore]
        public DataColumn DataColumn { get; set; }

        /// <summary>
        /// DQ列实体
        /// </summary>
        [JsonIgnore]
        public DataQueryColumn DataQueryColumn { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext1 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext2 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext3 { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [JsonIgnore]
        public string Creator { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>        
        [JsonIgnore]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 最后修改人
        /// </summary>
        [JsonIgnore]
        public string LastModifier { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>        
        [JsonIgnore]
        public DateTime LastModifyTime { get; set; }

        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }
}

